home *** CD-ROM | disk | FTP | other *** search
- Path: solon.com!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c,comp.lang.c.moderated
- Subject: Re: Floating Point arithmetic problem
- Date: 16 Feb 1996 00:12:39 -0600
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Sender: clc@solutions.solon.com
- Approved: clc@solutions.solon.com
- Message-ID: <4g178n$mu3@solutions.solon.com>
- References: <c968da6jzm.fsf@damayanti.india.ti.com> <4fvi3t$ebe@solutions.solon.com>
- NNTP-Posting-Host: solutions.solon.com
-
- In article <4fvi3t$ebe@solutions.solon.com>,
- Thad Smith <ThadSmith@acm.org> wrote:
- >That would, for arbitrary operands, make matters much worse by adding
- >additional noise. Your examples, though, suggest that all your values
- >might be multiples of .001 or .0001. If that is the case, you would
- >be much better off scaling your values by a multiplier that results in
- >all values being integers, i.e., multiplying by 10000, before summing
- >them. This will reduce the noise produced when adding the numbers,
- >probably enough to give you a perfect solution. Obviously you need to
-
- Yes. If there are enough significant bit in the mantissa of whatever
- floating-point representation is being used, then all the integers can be
- represented. E.g. the double-precision IEEE format has 52 bits, which is plenty
- for storing perfect representations of 32-bit integers. The solution I
- presented which converts an integer loop variable into floating point may be
- overkill if every integer can be accurately represented.
- --
-